panelmatch_resultframe(res_nonviolent_WW2, y = "Polyarchy", x = "Nonviolent After 1945")
))
era_results$strategy <- gsub("(.*iolent) .*", "\\1", era_results$treatment)
era_results$era <- gsub(".*iolent (.*)", "\\1", era_results$treatment)
era_results$era <- factor(era_results$era, levels = c("Before 1900", "After 1900", "After 1945"))
era_results$Time <- paste0("T+", era_results$time)
era_results$Time <- factor(era_results$Time, levels =  paste0("T+", 0:10))
era_results[, c("X2.5.", "X97.5.")] <- NULL
era_results$estimate  <- ifelse(abs(era_results$estimate) / abs(era_results$std.error) >= 1.97,  paste0( as.character(round(as.numeric(era_results$estimate) , 4)), "*"),
as.character(round(as.numeric(era_results$estimate) , 4)) )
era_results$std.error <- paste0( "(", round(as.numeric(era_results$std.error), 4), ")")
era_results <- era_results[ , c("estimate", "std.error", "Time", "treatment", "strategy", "era")]
viol_era_results <- era_results %>% subset(strategy == "Violent") %>% pivot_longer(estimate:std.error, values_to = "Violent") %>% select(-treatment, -strategy)
viol_era_results <- viol_era_results %>% pivot_wider(names_from = era, values_from = "Violent") %>% select(-name)
viol_ndat <- tibble("Time" = c("N treated", "Sum of control units"),
"Before 1900"     = as.character(c(length(res_violent_19th$matched.sets)   , sum(sapply(res_violent_19th$matched.sets   , function(x) length(x))) )),
"After 1900" = as.character(c(length(res_violent_20th$matched.sets), sum(sapply(res_violent_20th$matched.sets, function(x) length(x))) )),
"After 1945" = as.character(c(length(res_violent_WW2$matched.sets), sum(sapply(res_violent_WW2$matched.sets, function(x) length(x))) )))
viol_era_results <- bind_rows(viol_era_results, viol_ndat)
viol_era_results$Time[seq(2, nrow(viol_era_results)-2, 2)] <- ""
nvio_era_results <- era_results %>% subset(strategy == "Nonviolent") %>% pivot_longer(estimate:std.error, values_to = "Nonviolent") %>% select(-treatment, -strategy)
nvio_era_results <- nvio_era_results %>% pivot_wider(names_from = era, values_from = "Nonviolent") %>% select(-name)
nvio_ndat <- tibble("Time" = c("N treated", "Sum of control units"),
"Before 1900" = as.character(c(length(res_nonviolent_19th$matched.sets)  , sum(sapply(res_nonviolent_19th$matched.sets, function(x) length(x))) )),
"After 1900"  = as.character(c(length(res_nonviolent_20th$matched.sets)  , sum(sapply(res_nonviolent_20th$matched.sets, function(x) length(x))) )),
"After 1945"  = as.character(c(length(res_nonviolent_WW2$matched.sets)   , sum(sapply(res_nonviolent_WW2$matched.sets, function(x) length(x))) )))
nvio_era_results <- bind_rows(nvio_era_results, nvio_ndat)
nvio_era_results$Time[seq(2, nrow(nvio_era_results)-2, 2)] <- ""
addtorow <- list()
addtorow$pos <- list(nrow(viol_era_results))
addtorow$command <- paste0(paste0('\\hline \\multicolumn{5}{l}{', "\\textit{* p \\textless 0.05. Standard errors in parentheses}", '}', collapse=''), '\\\\')
#
print(xtable(viol_era_results, caption = "ATT for violent protest movements on subsequent Polyarchy-
scores across different time periods", label = "tab:era_results_violent"), add.to.row = addtorow, include.rownames = FALSE, caption.placement = "top", size = "scriptsize",
hline.after = c(-1, 0, nrow(viol_era_results)-2),
table.placement = "!htbp", file = "Output/TableC2.tex")
print(xtable(nvio_era_results, caption = "ATT for nonviolent protest movements on subsequent Polyarchy-
scores across different time periods", label = "tab:era_results_nonviolent"), add.to.row = addtorow, include.rownames = FALSE, caption.placement = "top", size = "scriptsize",
hline.after = c(-1, 0, nrow(nvio_era_results)-2),
table.placement = "!htbp", file = "Output/TableC3.tex")
flank_modeldat <- cy_omg[, c("country_id", "year", "onset_nonviolent_flank", "onset_violent_flank", "ongoing_violent_with_flank_lag1", "v2x_polyarchy", "ongoing_nonviolent_with_flank_lag1", "latent_gdppc_mean_log", "ln_pop")]
#PanelMatch
mod_violent_flank <- PanelMatch(
#General information for the PanelMatch-function:
data = flank_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_violent_flank", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("ongoing_violent_with_flank_lag1", "ongoing_nonviolent_with_flank_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_nonviolent, 1:10)) + I(lag(campaign_strategy_violent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_violent_flank <- PanelEstimate(sets = mod_violent_flank, data = flank_modeldat)
#PanelMatch
mod_nonviolent_flank <- PanelMatch(
#General information for the PanelMatch-function:
data = flank_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviolent_flank", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("ongoing_nonviolent_with_flank_lag1", "ongoing_nonviolent_with_flank_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #+ I(lag(campaign_strategy_nonviolent, 1:10)) + I(lag(campaign_strategy_violent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_nonviolent_flank <- PanelEstimate(sets = mod_nonviolent_flank, data = flank_modeldat)
#Result
flank_resframe <- data.frame(rbind(cbind(summary(res_violent_flank)$summary,
"Strategy"="Violent", "time" = paste0("t+", 0:10)),
cbind(summary(res_nonviolent_flank)$summary, "Strategy" = "Nonviolent", "time" = paste0("t+", 0:10))))
flank_resframe$estimate <- as.numeric(flank_resframe$estimate)
flank_resframe$X2.5. <- as.numeric(flank_resframe$X2.5.)
flank_resframe$X97.5. <- as.numeric(flank_resframe$X97.5.)
flank_resframe$time <- factor(flank_resframe$time, levels =  paste0("t+", 0:10))
flank_results <- ggplot(flank_resframe, aes(x = time, y = estimate, ymax = X97.5., ymin = X2.5., color = Strategy)) +
geom_point(size = 4, position = position_dodge(width = 0.1)) +
geom_errorbar(width = 0.1, linewidth = 2, position = position_dodge(width = 0.1)) +
geom_hline(yintercept = 0) +
theme_minimal() +
xlab("Years since movement start") +
ylab("Change in Polyarchy") +
scale_color_manual(values = c("black", "grey")) +
#labs(title = "ATT for campaigns of violent vs nonviolent strategy on Polyarchy over time") +
theme(axis.text = element_text(size = 18),
axis.title = element_text(size = 18),
legend.text = element_text(size = 18),
legend.title = element_text(size = 18),
plot.title = element_text(size = 18))
ggsave(filename = "Output/FigureC3.jpg", flank_results, width = 12, heigh = 8)
#Result
flank_resframe <- data.frame(rbind(cbind(summary(res_violent_flank)$summary,
"Strategy"="Violent", "Time" = paste0("T+", 0:10)),
cbind(summary(res_nonviolent_flank)$summary, "Strategy" = "Nonviolent", "Time" = paste0("T+", 0:10))))
#flank_resframe$estimate  <- as.character(round(as.numeric(flank_resframe$estimate) , 4))
flank_resframe$estimate <- as.numeric(flank_resframe$estimate)
flank_resframe$std.error <- as.numeric(flank_resframe$std.error)
flank_resframe$estimate  <- ifelse(abs(flank_resframe$estimate) / abs(flank_resframe$std.error) >= 1.97,  paste0( as.character(round(as.numeric(flank_resframe$estimate) , 4)), "*"),
as.character(round(as.numeric(flank_resframe$estimate) , 4)) )
flank_resframe$std.error <- paste0( "(", round(as.numeric(flank_resframe$std.error), 4), ")")
flank_resframe$X2.5.     <- as.numeric(flank_resframe$X2.5.)
flank_resframe$X97.5.    <- as.numeric(flank_resframe$X97.5.)
flank_resframe$Time <- factor(flank_resframe$Time, levels =  paste0("T+", 0:10))
flank_resframe <- flank_resframe[ , c("estimate", "std.error", "Time", "Strategy")]
viol_flank_resframe <- flank_resframe %>% subset(Strategy == "Violent") %>% pivot_longer(estimate:std.error, values_to = "Violent") %>% select(-Strategy)
nvio_flank_resframe <- flank_resframe %>% subset(Strategy == "Nonviolent") %>% pivot_longer(estimate:std.error, values_to = "Nonviolent") %>% select(-Strategy)
flank_resframe <- full_join(viol_flank_resframe, nvio_flank_resframe)
flank_resframe$name <- NULL
ndat <- tibble("Time" = c("N treated", "Sum of control units"),
"Violent"     = as.character(c(length(res_violent_flank$matched.sets)   , sum(sapply(res_violent_flank$matched.sets   , function(x) length(x))) )),
"Nonviolent" = as.character(c(length(res_nonviolent_flank$matched.sets), sum(sapply(res_nonviolent_flank$matched.sets, function(x) length(x))) )))
flank_resframe <- bind_rows(flank_resframe, ndat)
flank_resframe$Time[seq(2, nrow(flank_resframe)-2, 2)] <- ""
addtorow <- list()
addtorow$pos <- list(nrow(flank_resframe))
addtorow$command <- paste0(paste0('\\hline \\multicolumn{3}{l}{', "\\textit{* p \\textless 0.05. Standard errors in parentheses}", '}', collapse=''), '\\\\')
#
print(xtable(flank_resframe, caption = "ATT for violent vs. nonviolent protest movements on subsequent Polyarchy-
scores", label = "tab:Fullsample_results"), add.to.row = addtorow, include.rownames = FALSE, caption.placement = "top", size = "footnotesize",
hline.after = c(-1, 0, nrow(flank_resframe)-2),
table.placement = "!htbp", file = "Output/TableC10.tex")
fullsample_modeldat <- cy_omg[, c("country_id", "year", "onset_nonviolent", "onset_violent", "campaign_strategy_violent_lag1", "v2x_polyarchy", "campaign_strategy_nonviolent_lag1",
"v2svdomaut", "latent_gdppc_mean_log", "v2svindep", "e_civil_war", "ln_pop", "successful_coups")]
#PanelMatch
mod_violent_instability <- PanelMatch(
#General information for the PanelMatch-function:
data = fullsample_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_violent", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1", "v2svindep", "e_civil_war"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_nonviolent, 1:10)) + I(lag(campaign_strategy_violent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) + I(lag(v2svdomaut, 1:10)) + I(lag(successful_coups, 1:10)) ) #Formula for refinement
)
#Stage 3
res_violent_instability <- PanelEstimate(sets = mod_violent_instability, data = fullsample_modeldat)
#PanelMatch
mod_nonviolent_instability <- PanelMatch(
#General information for the PanelMatch-function:
data = fullsample_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviolent", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1", "v2svindep", "e_civil_war"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #+ I(lag(campaign_strategy_nonviolent, 1:10)) + I(lag(campaign_strategy_violent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) + I(lag(v2svdomaut, 1:10)) + I(lag(successful_coups, 1:10)) ) #Formula for refinement
)
#Stage 3
res_nonviolent_instability <- PanelEstimate(sets = mod_nonviolent_instability, data = fullsample_modeldat)
#Result
fullsample_resframe_instability <- data.frame(rbind(cbind(summary(res_violent_instability)$summary,
"Strategy"="Violent", "time" = paste0("t+", 0:10)),
cbind(summary(res_nonviolent_instability)$summary, "Strategy" = "Nonviolent", "time" = paste0("t+", 0:10))))
fullsample_resframe_instability$estimate <- as.numeric(fullsample_resframe_instability$estimate)
fullsample_resframe_instability$X2.5. <- as.numeric(fullsample_resframe_instability$X2.5.)
fullsample_resframe_instability$X97.5. <- as.numeric(fullsample_resframe_instability$X97.5.)
fullsample_resframe_instability$time <- factor(fullsample_resframe_instability$time, levels =  paste0("t+", 0:10))
fullsample_results_instability <- ggplot(fullsample_resframe_instability, aes(x = time, y = estimate, ymax = X97.5., ymin = X2.5., color = Strategy)) +
geom_point(size = 4, position = position_dodge(width = 0.1)) +
geom_errorbar(width = 0.1, linewidth = 2, position = position_dodge(width = 0.1)) +
geom_hline(yintercept = 0) +
theme_minimal() +
xlab("Years since movement start") +
ylab("Change in Polyarchy") +
scale_color_manual(values = c("black", "grey"))
ggsave(filename = "Output/FigureC4.jpg", fullsample_results_instability, width = 12, height = 8, scale =0.7)
ide_modeldat <- cy_omg[, c("country_id", "year", "campaign_strategy_violent_lag1", "v2x_polyarchy", "campaign_strategy_nonviolent_lag1", "latent_gdppc_mean_log", "ln_pop",
grep("^onset_", colnames(cy_omg), value =T))]
#####     Socialist
#PanelMatch
mod_socialist_violent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_viol_ide_socialist_marxist", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_socialist_violent <- PanelEstimate(sets = mod_socialist_violent, data = ide_modeldat)
#PanelMatch
mod_socialist_nonviolent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviol_ide_socialist_marxist", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_socialist_nonviolent <- PanelEstimate(sets = mod_socialist_nonviolent, data = ide_modeldat)
#####    Students
#PanelMatch
mod_demo_violent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_viol_ide_democracy_hr", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_demo_violent <- PanelEstimate(sets = mod_demo_violent, data = ide_modeldat)
#PanelMatch
mod_demo_nonviolent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviol_ide_democracy_hr", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_demo_nonviolent <- PanelEstimate(sets = mod_demo_nonviolent, data = ide_modeldat)
#####     Nationalist
#PanelMatch
mod_nationalist_violent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_viol_ide_nationalist", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_nationalist_violent <- PanelEstimate(sets = mod_nationalist_violent, data = ide_modeldat)
#PanelMatch
mod_nationalist_nonviolent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviol_ide_nationalist", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_nationalist_nonviolent <- PanelEstimate(sets = mod_nationalist_nonviolent, data = ide_modeldat)
#####     Peasants
#PanelMatch
mod_conservative_violent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_viol_ide_conservative", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_conservative_violent <- PanelEstimate(sets = mod_conservative_violent, data = ide_modeldat)
#PanelMatch
mod_conservative_nonviolent <- PanelMatch(
#General information for the PanelMatch-function:
data = ide_modeldat, #Data to be used
time.id = "year", #Name of time-column
unit.id = "country_id", #Name of unit-column
treatment = "onset_nonviol_ide_conservative", #Name of treatment variable
outcome.var = "v2x_polyarchy", #Name of outcome variable
qoi = "att", #Quantity of interest.
verbose = TRUE, #Prints more information about all calculations
#    Arguments for Stage 1:
matching = TRUE, #Should Stage 1 exact match on treatment history?
lag = 10, # This argument controls the number of lags, notated as "L" int he article
match.missing = FALSE, # Should patterns of missingness be included in matching the units into sets?
listwise.delete = TRUE, #Delete missingness listwise
exact.match.variables = c("campaign_strategy_nonviolent_lag1", "campaign_strategy_violent_lag1"), #In principle, the exact matching in stage 1 can include all categorical variables, not just the treatment history. Character vector of relevant categorical variables can be added here. NULL means that we will only match on treatment history.
#    Arguments referring to Stage 2:
lead = 0:10, #How far (years) into the future should the outcome be measured? Notated as F in the article
forbid.treatment.reversal = FALSE, #Should reversal be allowed in the period between the treatment occurs (T) and the outcome is measured (T + leads/F)
refinement.method = "CBPS.weight", #Covariate balancing propensity score weights from Imai and Ratkovic (2014)
size.match = 5, #Indicates the J closest matches to keep in the refinement. This is only relevant for the distance-methods, not weight-methods.
covs.formula = as.formula(~ I(lag(v2x_polyarchy, 1:10)) + #I(lag(campaign_strategy_violent, 1:10)) + I(lag(campaign_strategy_nonviolent, 1:10)) +
I(lag(latent_gdppc_mean_log, 1:10)) + I(lag(ln_pop, 1:10)) ) #Formula for refinement
)
#Stage 3
res_conservative_nonviolent <- PanelEstimate(sets = mod_conservative_nonviolent, data = ide_modeldat)
#####     Make results-frame
ide_result <- bind_rows(list(panelmatch_resultframe(res_socialist_violent, y = "Polyarchy", x = "Violent Socialism and Marxism"),
panelmatch_resultframe(res_socialist_nonviolent, y = "Polyarchy", x = "Nonviolent Socialism and Marxism"),
panelmatch_resultframe(res_demo_violent, y = "Polyarchy", x = "Violent Democracy and HR"),
panelmatch_resultframe(res_demo_nonviolent, y = "Polyarchy", x = "Nonviolent Democracy and HR"),
panelmatch_resultframe(res_nationalist_violent, y = "Polyarchy", x = "Violent Nationalism"),
panelmatch_resultframe(res_nationalist_nonviolent, y = "Polyarchy", x = "Nonviolent Nationalism"),
panelmatch_resultframe(res_conservative_violent, y = "Polyarchy", x = "Violent Conservativism"),
panelmatch_resultframe(res_conservative_nonviolent, y = "Polyarchy", x = "Nonviolent Conservativism") ) )
ide_result$strategy <- gsub("(.*iolent) .*", "\\1", ide_result$treatment)
ide_result$ide <- gsub(".*iolent (.*)", "\\1", ide_result$treatment)
ide_result$ide <- factor(ide_result$ide, levels = c("Socialism and Marxism", "Democracy and HR", "Nationalism", "Conservativism"))
ide_result$time <- factor(ide_result$time, levels = c(0:10))
ide_result_plot <- ggplot(ide_result, aes(x = time, y = estimate, ymax = X97.5., ymin = X2.5.)) +
facet_grid(ide ~ strategy) +
geom_point(size = 4, position = position_dodge(width = 0.1)) +
geom_errorbar(width = 0.1, linewidth = 2, position = position_dodge(width = 0.1)) +
geom_hline(yintercept = 0) +
theme_minimal() +
xlab("Years since movement start") +
ylab("Change in Polyarchy") +
#labs(title = "ATT for campaigns of violent vs nonviolent strategy on Polyarchy over time") +
theme(axis.text = element_text(size = 18),
axis.title = element_text(size = 18),
legend.text = element_text(size = 18),
legend.title = element_text(size = 18),
plot.title = element_text(size = 18),
strip.background = element_rect(fill = "grey80", color = "white"),
strip.text = element_text(size = 16))
ggsave(filename = "Output/Figure10.jpg", ide_result_plot, width = 12, heigh = 12)
#####     Make results-frame
ide_result <- bind_rows(list(panelmatch_resultframe(res_socialist_violent, y = "Polyarchy", x = "Violent Socialism and Marxism"),
panelmatch_resultframe(res_socialist_nonviolent, y = "Polyarchy", x = "Nonviolent Socialism and Marxism"),
panelmatch_resultframe(res_demo_violent, y = "Polyarchy", x = "Violent Democracy and HR"),
panelmatch_resultframe(res_demo_nonviolent, y = "Polyarchy", x = "Nonviolent Democracy and HR"),
panelmatch_resultframe(res_nationalist_violent, y = "Polyarchy", x = "Violent Nationalism"),
panelmatch_resultframe(res_nationalist_nonviolent, y = "Polyarchy", x = "Nonviolent Nationalism"),
panelmatch_resultframe(res_conservative_violent, y = "Polyarchy", x = "Violent Conservativism"),
panelmatch_resultframe(res_conservative_nonviolent, y = "Polyarchy", x = "Nonviolent Conservativism") ) )
ide_result$strategy <- gsub("(.*iolent) .*", "\\1", ide_result$treatment)
ide_result$ide <- gsub(".*iolent (.*)", "\\1", ide_result$treatment)
ide_result$ide <- factor(ide_result$ide, levels = c("Socialism and Marxism", "Democracy and HR", "Nationalism", "Conservativism"))
ide_result$time <- factor(ide_result$time, levels = c(0:10))
ide_result$Time <- paste0("T+", ide_result$time)
ide_result$Time <- factor(ide_result$Time, levels =  paste0("T+", 0:10))
ide_result[, c("X2.5.", "X97.5.")] <- NULL
ide_result$estimate  <- ifelse(abs(ide_result$estimate) / abs(ide_result$std.error) >= 1.97,  paste0( as.character(round(as.numeric(ide_result$estimate) , 4)), "*"),
as.character(round(as.numeric(ide_result$estimate) , 4)) )
ide_result$std.error <- paste0( "(", round(as.numeric(ide_result$std.error), 4), ")")
ide_result <- ide_result[ , c("estimate", "std.error", "Time", "treatment", "strategy", "ide")]
viol_ide_results <- ide_result %>% subset(strategy == "Violent") %>% pivot_longer(estimate:std.error, values_to = "Violent") %>% select(-treatment, -strategy)
viol_ide_results <- viol_ide_results %>% pivot_wider(names_from = ide, values_from = "Violent") %>% select(-name)
viol_ndat <- tibble("Time" = c("N treated", "Sum of control units"),
"Socialism and Marxism"      = as.character(c(length(res_socialist_violent$matched.sets)  , sum(sapply(res_socialist_violent$matched.sets   , function(x) length(x))) )),
"Democracy and HR"     = as.character(c(length(res_demo_violent$matched.sets) , sum(sapply(res_demo_violent$matched.sets, function(x) length(x))) )),
"Nationalism"    = as.character(c(length(res_nationalist_violent$matched.sets) , sum(sapply(res_nationalist_violent$matched.sets, function(x) length(x))) )),
"Conservativism" = as.character(c(length(res_conservative_violent$matched.sets) , sum(sapply(res_conservative_violent$matched.sets, function(x) length(x))) ))
)
viol_ide_results <- bind_rows(viol_ide_results, viol_ndat)
viol_ide_results$Time[seq(2, nrow(viol_ide_results)-2, 2)] <- ""
nvio_ide_results <- ide_result %>% subset(strategy == "Nonviolent") %>% pivot_longer(estimate:std.error, values_to = "Nonviolent") %>% select(-treatment, -strategy)
nvio_ide_results <- nvio_ide_results %>% pivot_wider(names_from = ide, values_from = "Nonviolent") %>% select(-name)
nvio_ndat <- tibble("Time" = c("N treated", "Sum of control units"),
"Socialism and Marxism"      = as.character(c(length(res_socialist_nonviolent$matched.sets)  , sum(sapply(res_socialist_nonviolent$matched.sets, function(x) length(x))) )),
"Democracy and HR"     = as.character(c(length(res_demo_nonviolent$matched.sets) , sum(sapply(res_demo_nonviolent$matched.sets, function(x) length(x))) )),
"Nationalism"    = as.character(c(length(res_nationalist_nonviolent$matched.sets) , sum(sapply(res_nationalist_nonviolent$matched.sets, function(x) length(x))) )),
"Conservativism" = as.character(c(length(res_conservative_violent$matched.sets) , sum(sapply(res_conservative_nonviolent$matched.sets, function(x) length(x))) ))  )
nvio_ide_results <- bind_rows(nvio_ide_results, nvio_ndat)
nvio_ide_results$Time[seq(2, nrow(nvio_ide_results)-2, 2)] <- ""
addtorow <- list()
addtorow$pos <- list(nrow(viol_ide_results))
addtorow$command <- paste0(paste0('\\hline \\multicolumn{5}{l}{', "\\textit{* p \\textless 0.05. Standard errors in parentheses}", '}', collapse=''), '\\\\')
#
print(xtable(viol_ide_results, caption = "ATT for violent protest movements on subsequent Polyarchy-scores across different social groups", label = "tab:ide_results_violent"), add.to.row = addtorow, include.rownames = FALSE, caption.placement = "top", size = "scriptsize",
hline.after = c(-1, 0, nrow(viol_ide_results)-2),
table.placement = "!htbp", file = "Output/TableC4.tex")
print(xtable(nvio_ide_results, caption = "ATT for nonviolent protest movements on subsequent Polyarchy-
scores across different social groups", label = "tab:ide_results_nonviolent"), add.to.row = addtorow, include.rownames = FALSE, caption.placement = "top", size = "scriptsize",
hline.after = c(-1, 0, nrow(nvio_ide_results)-2),
table.placement = "!htbp", file = "Output/TableC5.tex")
